; (function () {

  $.fn.vueCookbookOrder = function () {
    this.html(`
      <div class="cookbook-container">
        <div class="cookbook-col">
          <div class="cookbook-row cookbook-header">
            <span>日期</span>
            <span>餐次<span>(餐标)</span></span>
          </div>
          <div class="cookbook-row" v-for="(item, index) of eachMeal" :key="item.guid">
            <div>
              <span>{{ item.eachMealName }}</span>
            </div>
            <div v-for="it of item.mealPrices" :key="it.guid">
              <span>{{ it.price }}</span>
              <span style="color: #666666">元</span>
            </div>
          </div>
        </div>
        <div class="cookbook-col-day-wrapper">
          <div class="cookbook-col cookbook-col-day" v-for="item of mealData" :key="item.dateDay">
            <div class="cookbook-row cookbook-data">
              <div class="dateDay">{{ item.dateDay }}</div>
              <div class="week">({{ item.week }})</div>
              <span class="cookbook-rest" v-if="item.status == 'FALSE'">休</span>
            </div>
            <div class="cookbook-row cookbook-data" v-for="it of item.eachMeals" :key="it.canciGuid">
              <template v-if="it.status == 'TRUE'">
                <span class="cookbook-qi" v-if="it.isStart">起</span>
                <span class="cookbook-zhi" v-else-if="it.isEnd">止</span>
                <span class="cookbook-selected" v-else><span class="iconfont icon-icon"></span></span>
              </template>
              <span class="cookbook-rest" v-if="it.status == 'FALSE'" style="position: unset">休</span>
            </div>
          </div>
        </div>
      </div>
    `)
    new Vue({
      el: this[0],
      data() {
        return {
          eachMeal: [{
            guid: '1',
            eachMealName: '餐次名称1',
            mealPrices: [{
              guid: '1',
              price: '1.2'
            }]
          }, {
            guid: '2',
            eachMealName: '餐次名称2',
            mealPrices: [{
              guid: '2',
              price: '2.2'
            }]
          }, {
            guid: '3',
            eachMealName: '餐次名称3',
            mealPrices: [{
              guid: '3',
              price: '2.3'
            }]
          }],
          mealData: [{
            dateDay: '2022-05-05',
            week: '星期四',
            status: 'TRUE',
            eachMeals: [{
              canciGuid: '1',
              status: 'FALSE',
            }, {
              guid: '2',
              status: 'TRUE',
              isStart: true,
              isEnd: false,
            }, {
              guid: '3',
              status: 'TRUE',
              isStart: false,
              isEnd: false
            }]
          }, {
            dateDay: '2022-05-06',
            week: '星期五',
            status: 'TRUE',
            eachMeals: [{
              canciGuid: '1',
              status: 'TRUE',
            }, {
              guid: '2',
              status: 'TRUE',
              isStart: false,
              isEnd: false,
            }, {
              guid: '3',
              status: 'TRUE',
              isStart: false,
              isEnd: true
            }]
          }]
        }
      }
    })
  }

  /**
   * 生成guid
   * @param len
   * @param firstU
   * @param radix
   * @returns {string}
   */
  function guid(len = 32, firstU = true, radix = null) {
    let chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
    let uuid = [];
    radix = radix || chars.length;

    if (len) {
      // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位
      for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
    } else {
      let r;
      // rfc4122标准要求返回的uuid中,某些位为固定的字符
      uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
      uuid[14] = '4';

      for (let i = 0; i < 36; i++) {
        if (!uuid[i]) {
          r = 0 | Math.random() * 16;
          uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
        }
      }
    }
    // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guid不能用作id或者class
    if (firstU) {
      uuid.shift();
      return 'u' + uuid.join('');
    } else {
      return uuid.join('');
    }
  }

})();